//
//  ISWrongView.m
//  iPhoneSafety
//
//  Created by dlon 2019/1/5.
//  Copyright © 2019年 com.li.ding. All rights reserved.
//

#import "ISWrongView.h"
#import "UIColor+NWHex.h"
#import "ISGradientLayerView.h"
#import "NWLazyProperty.h"
#import "ISRingServer.h"
@interface ISWrongView()

@property (nonatomic, strong) ISGradientLayerView *bgView;
@property (nonatomic, strong) UIView *bgTextView;

@property (nonatomic, strong) UILabel *wrongLabel;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *contentLabel;

@end

@implementation ISWrongView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.bgView];
        
        [self addSubview:self.wrongLabel];
        [self addSubview:self.bgTextView];
        [self addSubview:self.titleLabel];
        [self addSubview:self.contentLabel];
        
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
        }];
        
        [self.wrongLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(90.f);
            make.centerX.equalTo(self);
        }];
        
        [self.bgTextView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.mas_centerY);
            make.left.right.equalTo(self).insets(UIEdgeInsetsMake(0, 38, 0, 38));
            make.height.equalTo(self.bgTextView.mas_width).multipliedBy(220.f/300.f);
        }];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.bgTextView).offset(18.f);
            make.centerX.equalTo(self.bgTextView);
        }];
        
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.titleLabel.mas_bottom).offset(30.f);
            make.left.right.equalTo(self.bgTextView).insets(UIEdgeInsetsMake(0, 17, 0, 17));
            make.bottom.lessThanOrEqualTo(self.bgTextView.mas_bottom).offset(-17.f);
        }];
        
    }
    return self;
}

#pragma mark - set & get
- (ISGradientLayerView *)bgView {
    if (!_bgView) {
        _bgView = [ISGradientLayerView new];
        CAGradientLayer *layer = (CAGradientLayer *)_bgView.layer;
        layer.startPoint = CGPointMake(0, 1);
        layer.endPoint = CGPointMake(0, 0);
        layer.colors = @[(id)[UIColor nw_colorWithHex:0x2C2F32].CGColor,(id)[UIColor nw_colorWithHex:0x34383D].CGColor];
    }
    return _bgView;
}

NWLazyPropertyWithInit(UILabel, wrongLabel, {
    _wrongLabel.font = [UIFont boldSystemFontOfSize:22.f];
    _wrongLabel.text = @"密码错误！";
    _wrongLabel.textColor = [UIColor whiteColor];
})

NWLazyPropertyWithInit(UILabel, titleLabel, {
    _titleLabel.font = [UIFont systemFontOfSize:14.f];
    _titleLabel.text = @"留言";
    _titleLabel.textColor = [UIColor nw_colorWithHex:0xffffff alpha:0.4];
})

NWLazyPropertyWithInit(UILabel, contentLabel, {
    _contentLabel.font = [UIFont systemFontOfSize:18.f];
    _contentLabel.textColor = [UIColor nw_colorWithHex:0xffffff alpha:1];
    _contentLabel.numberOfLines = 0;
    _contentLabel.text = [ISRingServer shareInstance].config.word;
})

NWLazyPropertyWithInit(UIView, bgTextView, {
    _bgTextView.backgroundColor = [UIColor nw_colorWithHex:0x97CAEA alpha:0.1];
})
@end
